package com.hs.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.sfzy.entity.Free;
import com.hs.sfzy.mapper.FreeMapper;
import com.hs.sfzy.service.FreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName FreeServiceImpl
 * @Description 公益中心服务层
 * @Author shanglin
 * @Date 2024年10月23日 20:50
 * @Version 1.0
 */
@Service
public class FreeServiceImpl implements FreeService {
    @Autowired
    private FreeMapper freeMapper;

    @Override
    public List<Free> selectAll(Free free) {
        return freeMapper.selectAll(free);
    }

    @Override
    public PageInfo<Free> selectByPageInfo(int pageNum, int pageSize, Free free) {
        PageHelper.startPage(pageNum,pageSize);
        List<Free> frees = freeMapper.selectAll(free);
        PageInfo<Free> pageInfo = new PageInfo<Free>(frees);
        return pageInfo;
    }

    @Override
    public int insert(Free free) {
        return freeMapper.insert(free);
    }

    @Override
    public int update(Free free) {
        return freeMapper.update(free);
    }

    @Override
    public int delete(int id) {
        return freeMapper.delete(id);
    }
}
